﻿

namespace Amplify.Twitter
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Security;
	using System.Text;


	public static class Mixins
	{
		/// <summary>
		/// Decrypts the encrypted value of the secure string.
		/// </summary>
		/// <param name="obj">The <see cref="System.Security.SecureString"/> </param>
		/// <returns>return an unsecure <see cref="System.String"/>.</returns>
		public static string Decrypt(this SecureString obj)
		{
			string value = "";
			IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(obj);
			try
			{
				value = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(ptr);
			}
			finally
			{
				System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(ptr);
			}
			return value;
		}
	}
}
